#define  _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    double a;
    int  b, c, d;
    while (scanf("%lf %d %d %d", &a, &b, &c, &d) != EOF) {
        if (b == 11 && c == 11)
        {
            a = a * 0.7;
        }
        else if (b == 12 && c == 12)
        {
            a = a * 0.8;
        }
        else {
            continue;
        }
        if (d == 0) {
            printf("%0.2lf ", a);
        }
        else
        {
            a -= 50;
            if (a < 0)
            {
                printf("0.00");
            }
            else
            {
                printf("%0.2lf", a);
            }
        }
    }
    return 0;
}